package com.cms.common.kit;

import javax.servlet.http.HttpServletRequest;

/**
 * request 操作工具类
 * @author life
 *
 */
public class RequestKit {

	/**
	 * 获取访问者IP
	 * @param request
	 * @return
	 */
	public static String getRemortIP(HttpServletRequest request) {  
	    if (request.getHeader("x-forwarded-for") == null) {  
	        return request.getRemoteAddr();  
	    }  
	    return request.getHeader("x-forwarded-for");  
	}
	
	/**
	 * 判断是否ajax访问
	 * @param request
	 * @return
	 */
	public static boolean isAjax(HttpServletRequest request) {
		return null != request.getHeader("x-requested-with") && "XMLHttpRequest".equals(request.getHeader("x-requested-with"));
	}
	
	
}
